package com.tomato.commons.exception;

import com.tomato.commons.errors.ErrorType;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * 系统程序异常
 */
@NoArgsConstructor
@Getter
@Setter
public class ApplicationException extends RuntimeException {

    private String code;
    private String message;

    public ApplicationException(ErrorType errorType) {
        super(errorType.message());
        this.message = errorType.message();
        this.code = errorType.code();
    }

    public ApplicationException(String message, Throwable cause) {
        super(message, cause);
        this.message = message;
    }

    public ApplicationException(Throwable cause) {
        super(cause);
    }

    public ApplicationException(String message) {
        super(message);
    }

    protected ApplicationException(String message, Throwable cause,
                                   boolean enableSuppression,
                                   boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.message = message;
    }
}
